package org.goldenmock.web.matchers;

import org.easymock.IArgumentMatcher;
import org.goldenmock.web.server.EasyHttpRequest;

/**
 * Implementation of IArgumentMatcher specifically for matchers that
 * handle matching of EasyRequests. Does some class checking and
 * casting that otherwise would have resulted in duplicate code.
 *
 * @author Robin Wagenaar
 * @author Arjen van Staalduinen
 */
abstract class EasyRequestMatcher implements IArgumentMatcher {

    protected abstract boolean matchesEasyRequest(EasyHttpRequest easyHttpRequest);

    @Override
    public boolean matches(Object actual) {
        //snot
        return (actual instanceof EasyHttpRequest) && matchesEasyRequest((EasyHttpRequest) actual);
    }

    @Override
    public void appendTo(StringBuffer stringBuffer) {
        stringBuffer.append(this.getClass()).append(" is executed");
    }
}
